/*
 * bsp_db_mysql.h
 *
 * Copyright (C) 2011 - Dr.NP
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef BSP_DB_MYSQL_H

#define BSP_DB_MYSQL_H                          1

#include "bsp_object.h"

#include "mysql.h"

// Definations
#define MYSQL_CONN_LIST_INITIAL                 256

#define CONN_MASK_IN_USE                        0b00000001
#define CONN_MASK_DB_SET                        0b00000010

// Macros

// Structs
struct mysql_conn
{
    int id;
    MYSQL *conn;
    u_int32_t srv_hash;
    u_int64_t queries;
    int mask;

    MYSQL_RES **result_list;
    size_t result_list_size;
};

// Functions
int db_mysql_init();
int db_mysql_connect(const char *, const char *, const char *, const char *, int);
int db_mysql_close(int);
int db_mysql_free_result(int, int);
int db_mysql_query(int, const char *, size_t);
int db_mysql_free_result(int, int);
int db_mysql_free_results(int);
int db_mysql_fetch_row(int, int, struct object_t *);

const char * db_mysql_error(int);

#endif  /* bsp_db_mysql.h */
